<!--
 * @Description: 盒模型
 * @Author: rendc
 * @Date: 2025-05-08 10:16:30
 * @LastEditors: rendc
 * @LastEditTime: 2025-05-08 11:12:20
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>盒模型</title>
</head>
<style>
  /* 清除默认样式 */
  html,body{
    margin: 0;
    padding: 0;
  }
  .main{
    font-size: 0px;
    border: 2px solid purple;
  }
  h1{
    font-size: 20px;
  }
  #div1,#div2,#div3,#div4{
    font-size: 16px;
    /* text-align: center; */
    display: inline-block;
    width: 100px;
    height: 100px;
    /* line-height: 100px; */
    color: white;
    font-weight: 700;
  }
  #div1{
    border: 1px solid rgba(255, 0, 0);
    background-color: rgba(255, 0, 0, 0.7);
    /* margin-top: 10px;
    margin-right: 10px;
    margin-bottom: 10px;
    margin-left: 10px; */
    /* margin: 10px 10px 10px 10px; */
    margin: 10px;
    padding: 10px;
  }
  #div2{
    border: 1px solid yellowgreen;
    background-color: yellowgreen;
    margin: 10px;
  }
  #div3{
    box-sizing:border-box;
    border: 1px solid rgba(255, 0, 0);
    background-color: rgba(255, 0, 0, 0.7);
    margin: 10px;
    padding: 10px;
  }
  #div4{
    box-sizing:border-box;
    border: 1px solid yellowgreen;
    background-color: yellowgreen;
    margin: 10px;
    padding: 10px;
  }
</style>
<body>
      <div class="main">
        <h1>
          默认盒⼦模型 W3C盒⼦ 内容盒子
        </h1>
        <div id="div1">
          div1
        </div>
        <!-- 此处的换行会造成页面解析空格 -->
        <!-- 解决方式1 不要换行 -->
        <!-- 解决方式2 设置字体大小为0 -->
        <div id="div2">
          div2
        </div>
      </div>
      <div class="main">
        <h1>
          边框盒⼦模型 IE盒⼦模型
        </h1>
        <div id="div3">
          div3
        </div>
        <!-- 此处的换行会造成页面解析空格 -->
        <!-- 解决方式1 不要换行 -->
        <!-- 解决方式2 设置字体大小为0 -->
        <div id="div4">
          div4
        </div>
      </div>
</body>
</html>